#!/bin/bash

TOMCAT_BASE_DIR=$1

echo "starting tomcat ..."

sh $TOMCAT_BASE_DIR/bin/startup.sh

java_pid=`ps  --no-heading -C java -f --width 1000 | grep "$TOMCAT_BASE_DIR" |awk '{print $2}'`
if [ ! -z "$java_pid" ]; then
    echo "tomcat server already started: pid=$java_pid"
    exit;
fi

echo "tomcat server start failed"
exit;